package com.guohe3.just.service.impl;

import com.guohe3.just.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * @author 浦希成
 * 2019-01-14
 */
@Service
@Slf4j
public class MailServiceImpl implements MailService {
    @Autowired
    private JavaMailSender mailSender;

    @Override
    public void sendTextMail(String text) {
        String[] toEmails = new String[]{"18852897377@163.com", "420326369@qq.com", "yueyong1030@outlook.com"};
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("2955317305@qq.com");
        message.setTo(toEmails);
        message.setSubject("主题：果核反馈信息");
        message.setText(text);
        mailSender.send(message);
        log.info("邮件发送成功：{}", text);
    }
}
